{extend name="public:_index" /}
{block name="title"}管理员管理{/block}
{block name="description"}描述{/block}
{block name="keywords"}关键词{/block}
{block name="heading"}管理员{/block}
{block name="breadcrumb"}管理员{/block}
{block name="wrapper"}
<div class="col-lg-12">
    <div class="">
        <button class="btn btn-default" onclick="admin_add('添加管理员', '{:url('admin/Admin/add')}', '600', '500');">
            <span class="icon16 entypo-icon-plus-2"></span>
            添加管理员
        </button>
        <div class="marginB10"></div>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading">
            <h4>
                <span class="icon16 icomoon-icon-numbered-list"></span>
                <span>管理员列表</span>
            </h4>
            <a href="#" class="minimize" style="display: none;">Minimize</a>
        </div>
        <div class="panel-body noPad">
            <div class="responsive" tabindex="5005" style="overflow: hidden; outline: none;">
                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <th>#</th>
                        <th>用户名</th>
                        <th>昵称</th>
                        <th>头像</th>
                        <th>邮箱</th>
                        <th>手机</th>
                        <th>状态</th>
                        <th>角色</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {volist name="data" id="vo"}

                    <tr>
                        <td>{$vo.id}</td>
                        <td>{$vo.username}</td>
                        <td>{$vo.nickname}</td>
                        <td>
                            <div class="internal_page_item internal_page_item_gallery">
                                <div class="overlay_a img-thumbnail">
                                    <img src="{if condition="$vo.image AND $vo.image.type neq 3"}{$vo.image.url}{else/}/images/unknow.png{/if}" alt="{$vo.nickname}" title="{$vo.nickname}" style="width:60px;">
                                    <div class="overlay">
                                        <a class="overlay_img cboxElement" href="{if condition="$vo.image AND $vo.image.type neq 3"}{$vo.image.url}{else/}/images/unknow.png{/if}" rel="lightbox" title="{$vo.nickname}"></a>
                                        <a class="overlay_project" href="javascript:void(0);" onclick="image_upload('上传图片', '{:url('admin/Image/upload', ['table'=>'admin','tid'=>$vo['id'], 'pid'=>3])}', '650', '526');"></a>
                                    </div>
                                </div>
                            </div>
                        </td>
                        <td>{$vo.email}</td>
                        <td>{$vo.phone}</td>
                        <td>
                            {if condition="$vo.status eq 0"} 禁用
                            {elseif condition="$vo.status eq 1"/} 启用
                            {else /} 未验证
                            {/if}
                        </td>
                        <td>
                            {if condition="$vo.roles"}
                                {volist name="vo.roles" id="role"}
                                    {$i>1?'，':''}{$role.role.name}
                                {/volist}
                            {/if}
                        </td>
                        <td>
                            <div class="controls center">
                                <a href="javascript:void(0);" class="tip" onclick="admin_edit('编辑管理员', '{$vo.id|url='admin/Admin/edit',['id'=>###]}', '600', '500');"  oldtitle="Edit task" title="编辑" data-hasqtip="true">
                                    <span class="icon12 icomoon-icon-pencil"></span>
                                </a>
                                <a href="javascript:void(0);" class="tip" onclick="admin_del(this, '{$vo.id}')" oldtitle="Remove task" title="删除" data-hasqtip="true">
                                    <span class="icon12 icomoon-icon-remove"></span>
                                </a>
                            </div>
                        </td>
                    </tr>
                    {/volist}
                    </tbody>
                </table>
            </div>
        </div>
    </div><!-- End .panel -->
</div>
{/block}

{block name="plugins_js"}

<script type="text/javascript" src="/static/js/common.js"></script>
<script type="text/javascript" src="/static/plugins/layer/layer.js"></script>
<script type="text/javascript" src="/static/js/jquery.colorbox-min.js"></script>
<script type="text/javascript" src="/static/js/jquery.custom.js"></script>
<script>
    /**
     * 图片上传
     * @param title
     * @param url
     * @param w
     * @param h
     */
    function image_upload(title, url, w, h){
        layer_show(title, url, w, h);
    }
    /**
     * 添加管理员
     * @param title
     * @param url
     * @param w
     * @param h
     */
    function admin_add(title, url, w, h){
        layer_show(title, url, w, h);
    }

    /**
     * 编辑管理员
     * @param title
     * @param url
     * @param w
     * @param h
     */
    function admin_edit(title, url, w, h){
        layer_show(title, url, w, h);
    }

    /**
     * 删除管理员
     * @param obj
     * @param id
     */
    function admin_del(obj, id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type: 'POST',
                data: {
                    id: id
                },
                url: '/amos/admin/delete.html',
                dataType: 'json',
                success: function(response){
                    if (response.status == 'success') {
                        $(obj).parents("tr").remove();
                        layer.msg('删除成功!',{icon:1,time:1000});
                    } else if ( response.status == 'failed') {
                        layer.msg('删除失败', {icon:2,time:1000});
                    }
                },
                error:function(data) {
                    layer.msg('请求失败!',{icon:2,time:1000});
                    console.log(data.msg);
                },
            });
        });
    }
</script>

{/block}